/* Copyright 2007 Sergejs Melderis (sergey.melderis@gmail.com)
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
*/

package com.sm.model;

import java.math.BigDecimal;
import java.util.Date;

/**
 *  @author Sergejs Melderis (sergey.melderis@gmail.com)
 */
public class Post {
    private BigDecimal postId;
    private User author;
    private Date createDate;
    private String content;
    private Category category;


    public Post() {

    }


    public BigDecimal getPostId() {
        return postId;
    }

    public void setPostId(BigDecimal postId) {
        this.postId = postId;
    }


    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    public User getAuthor() {
        return author;
    }

    public void setAuthor(User author) {
        this.author = author;
    }

    public Date getCreateDate() {
        return createDate;
    }

    public void setCreateDate(Date createDate) {
        this.createDate = createDate;
    }


    public void setCategory(Category category) {
        this.category = category;
    }

    public Category getCategory() {
        return category;
    }


    public String toString() {
        return "Post{" +
                "postId=" + postId +
                ", author=" + author +
                ", createDate=" + createDate +
                ", content='" + content + '\'' +
                ", category=" + category +
                '}';
    }


    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        Post post = (Post) o;

        if (!author.equals(post.author)) return false;
        if (!createDate.equals(post.createDate)) return false;
        if (!postId.equals(post.postId)) return false;

        return true;
    }

    public int hashCode() {
        int result;
        result = postId.hashCode();
        result = 31 * result + author.hashCode();
        result = 31 * result + createDate.hashCode();
        return result;
    }
}
